//
//  DefultVC.swift
//  letuofu
//
//  Created by dooland2 on 2020/6/28.
//  Copyright © 2020 WH-JS. All rights reserved.
//

import UIKit

class DefultVC: BaseViewControllerWithHeader {
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setupUI()
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

    func setupUI() {
        backButton.isHidden = true
        drawRightButton(imageName: "xiangqingkefu_82")
        .addTarget(self, action: #selector(_kefuButtonClick(button:)), for: .touchUpInside)
        
        let img = safeView.drawImage(named: "jiazaishibai_110") { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(-80)
            make.height.width.equalTo(200)
        }
        img.contentMode = .scaleAspectFit
        
        let lab = safeView.drawLabel(text: "您的商城权限已被移除\n如有疑问请联系人事管理员", fontSize: 19, textColor: .x333333) { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(img.snp.bottom).offset(10)
            make.width.equalToSuperview().offset(-56)
        }
        lab.textAlignment = .center
        lab.numberOfLines = 2
        
        let btn = safeView.drawButton(title: "重新登录", titleColor: .white, fontSize: 15) { (make) in
            make.top.equalTo(lab.snp.bottom).offset(40)
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(30)
            make.right.equalToSuperview().offset(-30)
            make.height.equalTo(35)
        }
        btn.backgroundColor = .xFC4C02
        btn.layer.cornerRadius = 7
        btn.addTarget(self, action: #selector(_onOKButtonClick(button:)), for: .touchUpInside)
    }
    
    
    @objc func _kefuButtonClick(button: Button) {
        let vc = M_SimpleArticleVC()
        pushViewController(vc)
        let qidiandic = LocalStorage.getDic(forKey: QIDIAN_KEY)
        vc.loadUrl(qidiandic?.getString("id") ?? "https://url.cn/50hfdES?_type=wpa&qidian=true")

        vc.headTitle.text = "联系客服"
    }
    
    
    @objc func _onOKButtonClick(button:Button){
        //确定执行
        self.popViewControllerToTop()
        LocalStorage.saveString("", forKey: LOGIN_PASSWORD)
    }
}
